package main

import (
	"log"
)

func main() {
	log.Println(reversePlus(123))
}

// 整数反转
// 123 -> 321
// -123 -> -321
// 120 -> 21
func reversePlus(x int) int {
	y := 0
	for x != 0 {
		y = y*10 + x%10
		if !(-(1<<31) <= y && y <= (1<<31)-1) {
			return 0
		}
		x /= 10
	}
	return y
}
